package com.shareppy.utils;

import java.util.List;

public class CollectionsUtil {

	private CollectionsUtil() {
		super();
	}

	public static String join(List<?> columns, char connector) {
		if (columns == null || columns.isEmpty()) {
			return null;
		}
		StringBuilder s = new StringBuilder();
		for (Object column : columns) {
			s.append(connector).append(column.toString());
		}
		return s.substring(1);
	}

	public static String[] toStringArray(Object[] array) {
		if (array == null) {
			return null;
		}
		String[] result = new String[array.length];
		for (int i = 0; i < array.length; i++) {
			Object item = array[i];
			if (item == null) {
				result[i] = null;
			} else {
				result[i] = item.toString();
			}
		}
		return result;
	}

}